home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: Etay_Bogner@mail.stil.scitex.com (Etay Bogner)
- Newsgroups: comp.std.c++
- Subject: Re: Calling X(int) from X()'s init list
- Date: 28 Feb 1996 16:16:46 GMT
- Organization: Scitex Corp.
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <Etay_Bogner-2802961057120001@metay.stil.scitex.com>
- References: <4gnush$phg@news.kth.se> <4gognf$et@news.bridge.net> <4gsa2r$gjm@sdaw04.seinf.abb.se> <Etay_Bogner-2702961023450001@metay.stil.scitex.com>
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- X-Nntp-Posting-Host: metay.scitex.com
- Content-Length: 1220
- X-Lines: 43
- Originator: clamage@taumet
-
- In article <Etay_Bogner-2702961023450001@metay.stil.scitex.com>,
- Etay_Bogner@mail.stil.scitex.com (Etay Bogner) wrote:
- << My inclination, although I rarly use const or reference data members, will
- << be to wrap those data members in an internal structure with it's own
- << constructor :
- <<
- << class A_Class_With_A_Const_Or_Refs {
- << A_Class_With_A_Const_Or_Refs(long& l);
- << struct internal_Data {
- << long& mLong;
- << const long mClassID; // when there was no RTTI, for instance
- << internal_Data(long& inLong, const long inID);
- << } mInternalData;
- << };
- <<
- << A_Class_With_A_Const_Or_Refs::A_Class_With_A_Const_Or_Refs(long& l) :
- << mInternalData(l, 'MYID') {}
- <<
- << and so on.
-
- I think it may be unclear :
-
- my suggestion is that one can write a *lot* of constructors, and they can
- call the internal constructor, which has the same effect as calling :
-
- class X {
- X(long);
- X(char*);
- };
-
- X::X(char* c) : X(1) {}
-
- Which is the desired behavior.
-
- --
- -- Etay Bogner
- -- Etay_Bogner@mail.stil.scitex.com
- -- Scitex Corp.
- -- Israel.
- --
- -- There are two rules for success in life:
- -- Rule 1: Don't tell people everything you know.
- --
-
-
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-